<?php 
if(isset($_SESSION['userid'])){
    if($member1['Permission']=="1"){
        $ThanhVien=0;
    }else{
        $ThanhVien=$_SESSION['userid'];
    }
}else{
    $ThanhVien=0;
}
include("includes/GetTrinhDuyet.php");
$ua=trinhduyet($_SERVER['HTTP_USER_AGENT']);
$sql = @mysql_query("select IP, IDOnline, Hits from online where IP = '".$_SERVER['REMOTE_ADDR']."' and ThanhVien = '$ThanhVien'");
if(mysql_num_rows($sql)>0){
    while ($rows = mysql_fetch_array($sql))
    {
    $Hits=$rows['Hits']+1;
    @mysql_query("UPDATE online SET Hits='$Hits', URL='".$_SERVER["REQUEST_URI"]."', Times='".date(time())."', ThanhVien='$ThanhVien', TrinhDuyet='".$ua['fname']." ".$ua['version']."' WHERE IDOnline = '".$rows['IDOnline']."'");
    }
}else{
    @mysql_query("INSERT INTO online(ThanhVien, Hits, IP, URL, Referrer, TrinhDuyet, HeDieuHanh, Times) VALUES('$ThanhVien', '1', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER["REQUEST_URI"]."', '".$_SERVER['HTTP_REFERER']."', '".$ua['fname']." ".$ua['version']."', '".$ua['platform']." ".$ua['platform1']."', '".date(time())."')");
}
?>